home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / FromTheMag / JW FLV MEDIA PLAYER 4.2 / mediaplayer.exe / player.swf / scripts / com / jeroenwijering / parsers / ATOMParser.as < prev    next >
Text File  |  2008-11-04  |  3KB  |  81 lines

  1. package com.jeroenwijering.parsers
  2. {
  3.    public class ATOMParser extends ObjectParser
  4.    {
  5.        
  6.       
  7.       public function ATOMParser()
  8.       {
  9.          super();
  10.       }
  11.       
  12.       public static function parse(param1:XML) : Array
  13.       {
  14.          var _loc2_:Array = null;
  15.          var _loc3_:Object = null;
  16.          var _loc4_:XML = null;
  17.          _loc2_ = new Array();
  18.          _loc3_ = new Object();
  19.          for each(_loc4_ in param1.children())
  20.          {
  21.             if(_loc4_.localName() == "entry")
  22.             {
  23.                _loc3_ = ATOMParser.parseItem(_loc4_);
  24.             }
  25.             if(_loc3_["type"] != undefined)
  26.             {
  27.                _loc2_.push(_loc3_);
  28.             }
  29.             _loc3_ = {};
  30.          }
  31.          return _loc2_;
  32.       }
  33.       
  34.       public static function parseItem(param1:XML) : Object
  35.       {
  36.          var _loc2_:* = undefined;
  37.          var _loc3_:XML = null;
  38.          var _loc4_:RegExp = null;
  39.          var _loc5_:RegExp = null;
  40.          var _loc6_:String = null;
  41.          _loc2_ = new Object();
  42.          for each(_loc3_ in param1.children())
  43.          {
  44.             switch(_loc3_.localName())
  45.             {
  46.                case "author":
  47.                   _loc2_["author"] = _loc3_.children()[0].text().toString();
  48.                   break;
  49.                case "title":
  50.                   _loc2_["title"] = _loc3_.text().toString();
  51.                   break;
  52.                case "summary":
  53.                   _loc2_["description"] = _loc3_.text().toString();
  54.                   break;
  55.                case "link":
  56.                   if(_loc3_.@rel == "alternate")
  57.                   {
  58.                      _loc2_["link"] = _loc3_.@href.toString();
  59.                   }
  60.                   else
  61.                   {
  62.                      _loc4_ = /^(.+)#(.+)$/g;
  63.                      _loc5_ = /^(.+)\.(.+)$/g;
  64.                      _loc6_ = _loc3_.@rel.toString().replace(_loc4_,"$2").replace(_loc5_,"$2");
  65.                      _loc2_[_loc6_] = _loc3_.@href.toString();
  66.                   }
  67.                   break;
  68.                case "published":
  69.                   _loc2_["date"] = _loc3_.text().toString();
  70.                   break;
  71.                case "group":
  72.                   _loc2_ = MediaParser.parseGroup(_loc3_,_loc2_);
  73.                   break;
  74.             }
  75.          }
  76.          _loc2_ = MediaParser.parseGroup(param1,_loc2_);
  77.          return ObjectParser.complete(_loc2_);
  78.       }
  79.    }
  80. }
  81.